﻿using System;
using System.Collections.Generic;
using System.Threading;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            Player blah = new Player();
            //blah.Open("Bleed.mp3");
            //blah.Play(false);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            WebClient client = new WebClient();
            Uri baseUri = new Uri("http://www.jessepiccolo.com");
            Uri myUri = new Uri(baseUri, "fire.jpg");

            textBox1.Text = "Downloading data from " + myUri;
            client.DownloadDataCompleted += new DownloadDataCompletedEventHandler(client_DownloadDataCompleted);
            client.DownloadDataAsync(myUri);

        }
        void client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
        {
            textBox1.Text = "File should be downloaded";
            FileStream fs = File.OpenWrite("cocks.mp3");
            byte[] myDataBuffer = e.Result;
            MemoryStream ms = new MemoryStream(e.Result);
           // pictureBox1.Image = Image.FromStream(ms);
            //fs.Write(ms.GetBuffer(), 0, Convert.ToInt32(ms.Position));
            //fs.Close();
            //Player blah = new Player();
            //blah.Open("cocks.mp3");
            //blah.Play(false);
        }

        //---------------------------------------------------------------------------------------------------------------
    }
}
